<!DOCTYPE html>
<html lang="en">
<!--script src方式引入vue和axios-->
<script src="js/plugins/vue/dist/vue.js"></script>
<script src="js/plugins/axios/dist/axios.js"></script>
<!--全局配置，以后只要用vue+axios的页面都引入common.js-->
<script src="js/common.js"></script>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="App"></div>
    <script type="text/javascript">
        new Vue({
            el:"#app",
            mounted(){
                var url = location.href
                var code = param2JsonObj(url).code;
                this.$http.get("/login/wechat/" + code).then(res=>{
                    if (res.data.success){
                        alert("登录成功！！！");
                        //提示
                        alert("登录成功!!!");
                        //保存token和logininfo对象到localStorage
                        var token = res.data.resultObj.token;
                        var logininfo = res.data.resultObj.logininfo;
                        localStorage.setItem("token",token);
                        //localStorage保存的数据是字符串，所以要将json对象转成jason格式的字符串
                    }else{//没有绑定
                        //跳转到绑定页面
                        var access_token = res.data.resultObj.access_token;
                        var openid = res.data.resultObj.openid;
                        location.href = "/binder.html?accessToken=" + access_token + "&openId=" + openid;
                    }
                }).catch(res=>{
                    alert("系统繁忙，请稍后重试！！！")
                })
            }
        })
    </script>
</body>
</html>